package MapAndSet;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class Test {
    public static void main(String[] args) {
        TreeMap<String,Integer> treeMap = new TreeMap<>();
        treeMap.put("nan",3);
        treeMap.put("jia",9);
        treeMap.put("ma",5);
        Integer ret =  treeMap.get("nan");
        System.out.println(ret);
        Integer val = treeMap.get("nan");
       Integer n =  treeMap.getOrDefault("nan",3);
        System.out.println(n);
        Set<Map.Entry<String,Integer>> entrySet = treeMap.entrySet();
        for (Map.Entry<String,Integer>entry: entrySet){
            System.out.println("key:"+entry.getKey()+" val "+entry.getValue());
        }
        Set<String> set = treeMap.keySet();
        treeMap.values();
    }
    public static void main1(String[] args) {
        BinarySearchTree bst = new BinarySearchTree();
        bst.insert(5);
        bst.insert(3);
        bst.insert(7);
        bst.insert(2);
        bst.insert(9);
        BinarySearchTree .TreeNode ret = bst.search(9);
        System.out.println(ret.val);
        bst.remove(5);
    }
}
